package com.asen.alibaba.controller;

import com.asen.alibaba.feign.UserControllerFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @ClassName Controller01
 * @Deacription TODO
 * @Author chenxin
 * @Date 2021/3/17 22:42
 **/
@RestController
@RequestMapping("/com")
public class Controller01 {

    @Autowired
    RestTemplate restTemplate;

    @Autowired
    UserControllerFeign userControllerFeign;

//    @RequestMapping("/list")
//    public List<User> list()
//    {
//        return restTemplate.getForObject("http://producer001/user/list", List.class);
//    }

    @RequestMapping("/list")
    public Object list()
    {
        return userControllerFeign.list();
    }

    @RequestMapping("/getById/{id}")
    public Object getById(@PathVariable("id")String id)
    {
        return userControllerFeign.getById(id);
    }
}
